package com.lyh.stock.server.impl;

import com.lyh.domain.bean.StockInfo;
import com.lyh.domain.server.StockInfoServer;
import com.lyh.dt.annotation.GroupTransaction;
import com.lyh.stock.dao.StockInfoMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

/**
 * @author liuyuhong
 */
@Service
@DubboService
public class StockInfoServerImpl implements StockInfoServer {

    @Autowired
    private StockInfoMapper mapper;

    @Override
    public StockInfo queryStockById(Long id) {
        return mapper.queryStockInfoById(id);
    }

    @Override
    @Transactional
    @GroupTransaction
    public void subStockByGoodsId(Long goodsId, BigDecimal count) {
        mapper.subStockByGoodsId(goodsId, count);
        int i = 10 / 0;
        System.out.println(i);
    }
}
